<template>
	<view class="">
		<!-- <tabsTop tabName="合美供销平台"></tabsTop> -->
		<!-- 是否有搜索框 -->
		<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="shop_scroll(e)">
			<view class="" v-if="isSearch">
				<mySearch class="searchClick" @click="searchClick()"></mySearch>
			</view>
			<!-- 顶部图片 -->
			<view class="w-100 img_box" style="" v-if="topdata.hasOwnProperty('topImg')">
				<!-- #99 调接口返回的数据 -->
				<swiper class="swiper swiper_height" circular :indicator-dots="false" autoplay="true" interval="2000"
					duration="2000" style="">
					<swiper-item style="width: 100%;height: 100%;" v-for="(item,index) in topdata.topImg" :key="index">
						<image style="height: 100%;" :src="Domain_ICON+item" class="img"></image>
						<!-- <image :src="'../../static/img/htyp_item'+topdata.topImg" mode="" class="img"></image> -->
					</swiper-item>
				</swiper>
			</view>
			<!-- 是否有导航 -->
			<view class="bg-white" v-if="this.navArr.length>0">
				<view class="mx-1 pt-2 flex justify-between flex-wrap">
					<view style="width: 20%;" class="flex flex-column align-center" v-for="(item,index) in navArr"
						:key="index" @click="navClick(item.ShopColumn_Id)">
						<view class="" style="width:110rpx;height: 110rpx;">
							<image :src="Domain_IMG+item.img" alt="" class="img">
							</image>
						</view>
						<view class="flex justify-center align-center py-3 mb-2"
							style="font-size: 25rpx;flex-wrap: nowrap;">
							{{item.name}}
						</view>
					</view>
				</view>
			</view>
			<!-- 商品详情图 -->
			<view class="flex flex-wrap" v-if="midImg.length>0">
				<view class="" style="width: 50%;height:300rpx" v-for="(item,index) in midImg" :key="index">
					<image :src="Domain_IMG+item" mode="" class="img"></image>
				</view>
			</view>

			<!-- 根据省份判读是否存在当前模块-->
			<view v-if="proCity.pro_location.length>0||proCity.city_location.hasOwnProperty('city')">
				<!-- 有省份显示省份模块 -->
				<view v-if="proCity.pro_location.length>0" class="flex flex-wrap justify-between px-2"
					style="background-color: #fff;">
					<!-- #99 调接口返回的数据 -->
					<view class="sheng_mokuai flex mt-3 justify-between align-center" v-for="(item,index) in proCity.pro_location"
						:key="index" style="height:200rpx" @click="provinceClick(item.Province_Name,'0')">
						<view class="left flex flex-column justify-center align-center">
							<text class="font-md font-weight-bolder mb-2">{{item.Province_Name}}</text>
							<view class="font-sm font-weight-bolder py px-2 rounded-lg" style="border:1px solid #000">
								点击进入
							</view>
						</view>
						<view class="" style="width: 130rpx;height:130rpx;">
							<!-- #99 调接口返回的数据 -->
							<image :src="Domain_IMG+item.Picture_URL" mode="" class="img rounded-circle"></image>
						</view>
					</view>
				</view>
				<!-- 有省有市显示的模块 -->
				<!-- 省市地址 -->

				<view class="flex flex-wrap justify-between px-2" style="background-color: #fff;" v-else>
					<view class="sheng_mokuai paddingcity_name flex mt-3 justify-between align-center flex-shrink"
						v-for="(item,index) in proCity.city_location.city" :key="index" style=""
						@click="provinceClick(item.city_name,'1')">
						<view class="left flex flex-column justify-center">
							<view class="">
								<text class="font">{{proCity.city_location.Province}}</text><br>
								<text class="font">{{item.city_name}}</text>
							</view>
							<!-- <view class="flex justify-center align-center font font-weight-bolder px-2 rounded-circle mt-1" style="border:1px solid #000;width:40%">
							<text class="pl-1 mr-1">GO</text><uni-icons type="right" size="20"></uni-icons>
						</view> -->
						</view>
						<view class="" style="width: 130rpx;height:130rpx;">
							<!-- #99 调接口返回的数据 -->
							<image :src="Domain_ICON+item.Picture_URL" mode="aspectFit" class="img rounded-circle">
							</image>
						</view>
					</view>
				</view>
			</view>
			<!-- 商品列表模块 -->
			<!-- botdata.length> -->
			<view class="product-list px-3 pt-2" style="background-color: #000;">
				<view class="sign_row flex flex-wrap pt-1">
					<!-- 循环生成两个商品数据 -->
					<!-- #99 要改的参数 -->
					<view class="bg-white mb-3 rounded-lg overflow-hidden goods_item" v-for="(item,index) in goods"
						:key="index" style="width: 330rpx;margin-left: 0.15%;"
						@click="productClick(item.Article_Name,item.Article_SerialNumber,item.Sales_Unit_Price_SerialNumber,item.Store_SerialNumber,item.ShopColumn_Id)">
						<view class="w-100" style="height: 350rpx;">
							<image :src="Domain_IMG+item.Picture_URL " :alt="item.Article_serialNumber" mode="aspectFit"
								class="img">
							</image>
						</view>
						<view class="px-2 w-100 " style="box-sizing: border-box;">
							<!-- 这行根据数据显示人气第几 -->
							<!-- <view class="product-name pt-2 font-sm"></view> -->
							<view class="flex justify-between flex-column py-3 ">
								<!-- 商品名 -->
								<view class="font-sm" style="height: 50rpx;">
									<text class="text-ellipsis-2"> {{item.Article_Name}}</text>
								</view>
								<view class="flex justify-between mt-3">
									<!-- 商品价格 -->
									<view class="flex align-center align-center">
										<money :money="item.Sales_Unit_Price+'' "></money>
									</view>
									<!-- 马上抢 -->
									<view style="width: 40rpx; height: 40rpx;" @click.stop="shopCart(item)">
										<image :src="Domain_ICON+'/shopcart.png'" mode="" class="img" style="">
										</image>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<botSponsor></botSponsor>
		</scroll-view>
		<!-- 购物车弹窗 -->
		<popUp type="top" bgColor="#fff" :show='shopcart' @Close="()=>{shopcart=false}" Height="70">
			<view class="shopcart flex ml-3" style="width: 70%;">
				<view class="getValue" :data-Article_SerialNumber="good.Article_SerialNumber"
					:data-quantity="good.quantity"
					:data-Unit_Price="good.specifications[0]?good.specifications[0].Unit_Price:''">
				</view>
				<view class="py-3" style="width:270rpx;height: 270rpx;">
					<image :src="Domain_IMG+good.Picture_URL" mode="aspectFit" class="img"></image>
				</view>
				<!-- 商品规格只有一个时 -->
				<view class="ml-2 flex flex-column justify-end pb-4" style="width: 200rpx;"
					v-if="good.hasOwnProperty('specifications')&&good.specifications.length==1">
					<money :money="good.specifications[0].Sales_Unit_Price"></money>
					<view class="font-sm" style="color: #ccc;">
						<text>剩余{{good.specifications[0].Stock_Remain}}件</text>
					</view>
				</view>
				<!-- 商品规格大于一个时 -->
				<view class="ml-2 flex flex-column justify-end pb-4" style="width: 200rpx;"
					v-if="good.hasOwnProperty('specifications')&&good.specifications.length>1">
					<!-- 未选中时显示 -->
					<view class="" v-if="JSON.stringify(selectSpe)=='{}'">
						<view class="flex">
							<money :money="minPrice"></money>-
							<money :money="maxPrice"></money>
						</view>

						<view class="font-sm" style="color: #ccc;">
							<text>剩余{{totalRemain}}件</text>
						</view>
						<view class="font-sm" style="color: #ccc;">
							<text>请选择 购买规格</text>
						</view>
					</view>
					<!-- 选中时显示 -->
					<view class="" v-else>
						<money :money="selectSpe.Sales_Unit_Price"></money>
						<view class="font-sm" style="color: #ccc;">
							<text>剩余{{selectSpe?selectSpe.Stock_Remain:''}}件</text>
						</view>
						<view class="font-sm" style="color: #ccc;">
							<text>已选 {{selectSpe.Specifications_Name}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="flex flex-column mx-3" v-if="good.specifications.length>1">
				<view class="">
					购买规格
				</view>
				<view class="flex">
					<view class="mr-2 rounded-lg flex justify-center align-center" :class="{'speActive':item.isSelect}"
						@click="speClick(item,index)" v-for="(item,index) in good.specifications" :key="index"
						style="background-color: rgb(247,248,250);width: 130rpx;height: 60rpx;">
						<view>
							{{item.Specifications_Name}}
						</view>
					</view>
				</view>
			</view>
			<view class="flex justify-between mx-3 mt-3">
				<view class="font">购买数量</view>
				<view class="">
					<counter :num="good.quantity"
						:max="Number(good.specifications[0]?good.specifications[0].Stock_Remain:'')"
						@Count="counterClick">
					</counter>
				</view>
			</view>
			<view class="shop-cart position-fixed flex justify-center font text-white "
				style=" bottom:20rpx; margin:0 auto">
				<button class="btn-left text-white" :disabled="loading" @click="addCart()">加入购物车</button>
				<button class="btn-right text-white" @click="buyNow()">立即购买</button>
			</view>
		</popUp>

		<tabsBottom></tabsBottom>
	</view>
</template>

<script>
	const app = getApp();
	import tabsTop from "@/components/tabs/tabs-top.vue";
	import tabsBottom from "@/components/tabs/tabs-bottom.vue";
	import botSponsor from "@/components/botsponsor/sponsor.vue"
	import popUp from "@/components/tabs/pop-up.vue"
	import {
		getHMGXLocation,
		getHMGXGoods
	} from "@/api/index.js"
	import mySearch from "@/components/mysearch/mysearch.vue"
	import {
		getColumnConfig,
		getWX2GoodsIdAction,
		getWX3GoodsIdAction
	} from "@/api/index.js"
	import money from "@/components/tool/money.vue"
	import counter from "@/components/tool/counter.vue"
	import {
		getAddAction,
		getJsonInquiry,
		getInquiryTourist,
		GetChengXu
	} from "@/api/global.js"
	import {
		getWXCheckShopCarAction,
		editWXEditShopCarQuantity,
		getWX4GoodsIdAction,
	} from "@/api/article.js"
	import {
		NowTime
	} from "@/static/js/DateUtil.js"
	import {
		accMul,intervalRange
	} from "@/static/js/GeneralUtil.js"
	import yHeader from "@/components/yHeader.vue"
	export default {
		components: { //轮播图组件
			tabsTop,
			tabsBottom,
			botSponsor,
			mySearch,
			popUp,
			money,
			counter,
			yHeader
		},
		data() {
			return {
				Domain_ICON: app.globalData.Domain_ICON,
				Domain_IMG: app.globalData.Domain_IMG,
				Domain_dead: app.globalData.Domain_dead,
				topdata: {}, // 顶部拿回来的数据
				botdata: [], // 底部拿回来的数据
				proCity: {
					pro_location: [],
					city_location: []
				}, //存放省份+城市
				isSearch: false, // 判断是否有搜索框
				midImg: '', //  中间位置是否有商品详情图片，有就显示
				goods: [], //  多种商品
				good: {
					specifications: []
				}, // 点击单个商品获取商品信息
				selectSpe: {}, // 选中的规格
				selectIndex: 5, // 选中规格的索引
				good_form: {
					ShopColumn_Id: '',
					Open_ID: app.globalData.Open_ID,
					page: 1,
					limit: 10,
					Article_Name: '',
					Category_SerialNumber: '',
					Enterprise_Info_SerialNumber: app.globalData.Enterprise_Info_SerialNumber
				},
				goodLimit: 0, //商品总数
				navArr: [], // 导航
				shopcart: false,
				loading: false,
				ShopColumn_Id: '', //当前的栏目
				totalRemain: 0, // 未选中时所有商品的总剩余
				minPrice: 0, // 规格中价格最小
				maxPrice: 0, // 规格中价格最大
				screenWidth: uni.getSystemInfoSync().windowWidth
			}
		},
		onLoad(option) {
			if (option.json_url && option.ShopColumn_Id) {
				this.ShopColumn_Id = option.ShopColumn_Id
				this.getJsonData(option.json_url, option.ShopColumn_Id)
				//console.log(option.ShopColumn_Id);
				if (option.ShopColumn_Id == "C00000000000022") {
					// this.getWX2GoodsIdAction("C00000000000044")
					this.getWX3GoodsIdAction("C00000000000044")
				} else {
					this.getWX3GoodsIdAction(this.ShopColumn_Id)
				}
				//  else {
				// 	//console.log(option.ShopColumn_Id);
				// 	// this.getWX2GoodsIdAction(option.ShopColumn_Id)
				// 	// this.getWX3GoodsIdAction(option.ShopColumn_Id)
				// }
			} else {
				// this.getData(option.ShopColumn_Id);
			}
			if (option.ShopColumn_Id) {
				// this.getWX2GoodsIdAction(option.ShopColumn_Id)
				// this.getWX3GoodsIdAction(option.ShopColumn_Id)
				if (option.ShopColumn_Id == "C00000000000021") {
					this.getData()
				}
			}
		},
		methods: {
			// 滚动底部加载商品
			shop_scroll() {
				if (this.ShopColumn_Id == "C00000000000002") {
					uni.showToast({
						title: "已加载全部商品",

						duration: 1500
					})
				} else {
					if (this.goods.length <= 40 && this.goods.length < this.goodLimit) {
						if (this.ShopColumn_Id == "C00000000000022") {
							// this.getWX2GoodsIdAction("C00000000000044")
							this.getWX3GoodsIdAction("C00000000000044")
						} else {
							this.getWX3GoodsIdAction(this.ShopColumn_Id)
						}
						uni.showToast({
							title: "正在加载商品",
							icon: "loading",
							duration: 1500
						})
					} else {
						uni.showToast({
							title: "已加载全部商品",

							duration: 1500
						})
					}
				}
			},
			// sssssss
			//调json查当前页面有哪些配置
			async getJsonData(File, ShopColumn_Id) {
				const res = await getJsonInquiry({
					File
				})
				if (res.Status == 'success') {
					let jsonres = JSON.parse(res.Data).Data
					//console.log(jsonres);
					for (var i = 0; i < jsonres.length; i++) {
						if (jsonres[i].ShopColumn_Id == ShopColumn_Id) {
							//console.log(jsonres[i]);
							// 判断是否存在顶部图片
							if (jsonres[i].hasOwnProperty('img')) {
								this.$set(this.topdata, "topImg", jsonres[i].img)
								// this.topdata['topImg'] = res.Data.img
							}
							// 判断是否存在搜索框
							if (jsonres[i].hasOwnProperty('isSearch')) {
								this.isSearch = jsonres[i].isSearch
							}
							if (jsonres[i].hasOwnProperty('navArr')) {
								this.navArr = jsonres[i].navArr;
								//console.log(this.navArr);
							}
							if (jsonres[i].hasOwnProperty('city_location')) {
								this.$set(this.proCity, 'city_location', jsonres[i].city_location)
								//console.log(this.proCity);
							}
							// await this.getWX2GoodsIdAction("C00000000000001");
						}
					}
				}
			},
			navClick(ShopColumn_Id) {
				uni.reLaunch({
					//搜索页路径
					url: "/pages/index/gongyou?ShopColumn_Id=" + ShopColumn_Id + '&json_url=' +
						'hmgx/shopGxgj_item.json',
				});
			},
			// 获取省份地址
			async getData() {
				const res = await getInquiryTourist({
					Data: "article_province",
					isNullEnterprise: true
				})
				// //console.log(res,'gggg')
				// //console.log(this.Domain_IMG+res[0].Picture_URL)
				//console.log(123);
				let loca = res
				this.$set(this.proCity, 'pro_location', loca)
				//console.log(this.proCity.pro_location, '省份地址');
				// if(res.Status == 'success'){
				// 	// this.ldbk =  JSON.parse(res.Data) 
				// }
			},
			// async getData(ShopColumn_Id) {
			// 	const res = await getColumnConfig({
			// 		ShopColumn_Id,
			// 		Open_ID: app.globalData.Open_ID
			// 	});
			// 	//console.log(res, '顶部图片');
			// 	// 判断是否存在顶部图片
			// 	if (res.Data.hasOwnProperty('img')) {
			// 		this.$set(this.topdata, "topImg", res.Data.img)
			// 		this.topdata['topImg'] = res.Data.img
			// 	}
			// 	// 判断是否存在地址
			// 	if (res.Data.hasOwnProperty('procity')) {
			// 		this.$set(this.proCity, "procity", res.Data.procity.procity)
			// 		this.$set(this.proCity, "City", res.Data.procity.City)
			// 	}
			// 	//console.log(this.proCity);
			// 	// 
			// },
			// async getWX2GoodsIdAction(ShopColumn_Id) {
			// 	this.good_form.ShopColumn_Id = ShopColumn_Id
			// 	const res = await getWX2GoodsIdAction(this.good_form)
			// 	this.good_form.page++
			// 	//console.log(res, '商品');
			// 	if (res.Status == "success") {
			// 		this.goods = res.tableData;
			// 		this.goods.reverse()
			// 	}

			// 	//console.log(res, '商品');
			// },
			async getWX3GoodsIdAction(ShopColumn_Id) {
				this.good_form.ShopColumn_Id = ShopColumn_Id
				const res = await getWX3GoodsIdAction(this.good_form)
				this.good_form.page++
				//console.log(res, '商品');
				if (res.Status == "success") {
					res.tableData.forEach((item, index) => {
						this.goods.push(item)
					})
					this.goodLimit = res.limit
					// this.goods = res.tableData
				}
				//console.log(res, '商品');
			},
			// 点击商品,进入商品详情页
			// 点击商品,进入商品详情页
			async productClick(name, Article_SerialNumber, Sales_Unit_Price_SerialNumber, Store_SerialNumber, ShopColumn_Id) {
				const data = await GetChengXu()
				//#测试
				if (app.globalData.isPC) {
					// https://marketing.ediblefungus.cn/dist/h5XKLJ/index.html/
					// http://localhost:8080/dist/h5XKLJ/
						// if(this.screenWidth < 480){
					window.location.href =app.globalData.Domain_Url+ `#/pages/detail/supply-detail?id=${encodeURIComponent(
						Article_SerialNumber)}&ShopColumn_Id=${encodeURIComponent(ShopColumn_Id)}&shop_good=${"shop_good"}`
				} else {
					uni.navigateTo({
						url: "/pages/index/productDetails?name=" + name + "&Article_SerialNumber=" +
							Article_SerialNumber + "&Sales_Unit_Price_SerialNumber=" +
							Sales_Unit_Price_SerialNumber +
							"&Store_SerialNumber=" + Store_SerialNumber + '&ShopColumn_Id=' + ShopColumn_Id
					})
				}

				// uni.navigateTo({
				// 	url: "/pages/index/productDetails?name=" + name + "&Article_SerialNumber=" +
				// 		Article_SerialNumber + "&Sales_Unit_Price_SerialNumber=" + Sales_Unit_Price_SerialNumber +
				// 		"&Store_SerialNumber=" + Store_SerialNumber + "&ShopColumn_Id=" + ShopColumn_Id
				// })
			},
			provinceClick(name, index) {
				uni.navigateTo({
					url: "/pages/index/manygoods?Province=" + name + '&index=' + index
				})
			},
			// 点击购物车图标，出现购物车弹窗
			async shopCart(item) {
				// const data = await GetChengXu()
				if (app.globalData.isPC) {
					window.location.href =app.globalData.Domain_Url+ `#/pages/detail/supply-detail?id=${encodeURIComponent(
						item.Article_SerialNumber)}&ShopColumn_Id=${encodeURIComponent(item.ShopColumn_Id)}&shop_good=${"shop_good"}`
				}else{
					this.totalRemain = 0;
					this.loading = false;
					this.good = {
						...item
					}
					const res = await getWX4GoodsIdAction({
						ShopColumn_Id: item.ShopColumn_Id,
						Article_SerialNumber: item.Article_SerialNumber,
						Enterprise_Info_SerialNumber: item.Enterprise_Info_SerialNumber,
						Open_ID: app.globalData.Open_ID
					})
					this.$set(this.good, "specifications", res.Data)
					this.$set(this.good, "quantity", 1)
					let obj = intervalRange(res.Data,'Sales_Unit_Price')
					//console.log(obj);
					this.minPrice = obj.min;
					this.maxPrice = obj.max;
					this.good.specifications.forEach((item, index) => {
						item.isSelect = false;
						this.totalRemain += item.Stock_Remain * 1;
					})
					// 传入需要拿到数据的选择器
					this.shopcart = !this.shopcart;
				}
			},
			// 选择商品规格
			speClick(item, index) {
				if (item.isSelect == false) {
					this.good.specifications.forEach(item => {
						this.$set(item, 'isSelect', false)
					})
					this.$set(this.good.specifications[index], 'isSelect', !this.good.specifications[index].isSelect)
					//console.log(this.good.specifications[index].isSelect);
					this.selectSpe = {
						...item
					}
					this.selectIndex = index
					//console.log(item, '选中的规格');
				} else {
					this.$set(this.good.specifications[index], 'isSelect', !this.good.specifications[index].isSelect)
					this.selectSpe = {}
					this.selectIndex = ''
					//console.log('置空');
				}
			},
			// 购物车中立即购买
			buyNow() {
				if (this.good.specifications.length > 1) {
					if (Object.keys(this.selectSpe).length <= 0) {
						uni.showToast({
							title: '请选择规格',
							icon: "error",
							duration: 1200
						})
						return;
					}
				} else {
					this.selectIndex = 0
				}
				if (this.good.quantity > 0) {

				} else {
					this.good.quantity = 1;
				}
				let Article = {
					Article_Name: this.good.Article_Name,
					Store_SerialNumber: this.good.Store_SerialNumber,
					Category_Name: "普通实物商品",
					Article_SerialNumber: this.good.specifications[this.selectIndex].Article_SerialNumber,
					Picture_URL: this.good.Picture_URL,
					Specifications_Name: this.good.specifications[this.selectIndex].Specifications_Name,
					Article_Specifications_SerialNumber: this.good.specifications[this.selectIndex]
						.Article_Specifications_SerialNumber,
					Sales_Unit_Price: this.good.specifications[this.selectIndex].Sales_Unit_Price,
					Sales_Unit_Price_Stock_SerialNumber: this.good.specifications[this.selectIndex]
						.Sales_Unit_Price_Detail_SerialNumber,
					Sales_Unit_Price_Detail_SerialNumber: this.good.specifications[this.selectIndex]
							.Sales_Unit_Price_Stock_SerialNumber,
					Sign: this.good.specifications[this.selectIndex].Sign,
					Stock_Remain: this.good.specifications[this.selectIndex].Stock_Remain,
					Stock_Sell: this.good.specifications[this.selectIndex].Stock_Sell,
					Quantity: this.good.quantity,
					Unit_Price: this.good.specifications[this.selectIndex].Unit_Price,
					Gifts: this.good.specifications[this.selectIndex].Children.Gifts
				}
				uni.navigateTo({
					url: "/pages/index/submitOrder?good=" + encodeURIComponent(JSON.stringify([Article]))
				})
			},
			// 购物车弹窗计数器
			counterClick(e) {
				this.good.quantity = e;
			},
			// 判断购物车有无相同商品
			async getWXCheckShopCarAction(Article_SerialNumber) {
				var res = await getWXCheckShopCarAction({
					App_ID: app.globalData.App_ID,
					Open_ID: app.globalData.Open_ID,
					Article_SerialNumber
				})
				return res;
			},
			// 加入购物车
			async addCart() {
				if (this.good.specifications.length > 1) {
					if (Object.keys(this.selectSpe).length <= 0) {
						uni.showToast({
							title: '请选择规格',
							icon: 'error',
							duration: 1200
						})
						return;
					}
				}
				this.loading = true;
				if (!this.good.quantity) {
					this.good.quantity = 1
				}
				let index = 0;
				this.good.specifications.forEach((item, index1) => {
					if (item.isSelect) {
						index = index1;
					}
				})
				// //console.log(this.good,'看看index');
				// 根据每个里的isSelect选中状态判断
				//console.log(this.good.specifications[index].Article_SerialNumber);
				let time = new Date().getTime();	
				var sales_order = {
					Sales_Order_SerialNumber: app.globalData.Open_ID+'_'+ time,
					Store_SerialNumber: this.good.Store_SerialNumber,
					Sales_Address: '',
					Sales_Contacts: '',
					Stock_Remain: this.good.specifications[index].Stock_Remain,
					Sales_Phone: '',
					Sales_Message: '',
					Sales_Date: NowTime(),
					Open_ID: app.globalData.Open_ID,
					App_ID: app.globalData.App_ID,
					Sales_Amount: accMul(this.good.quantity,this.good.specifications[index].Sales_Unit_Price),
					Collection_Amount: 0,
					Delivery_Amount: 0,
					Receive_Type: 0,
					Refund_Type: 0,
					Enterprise_Info_SerialNumber: app.globalData.Enterprise_Info_SerialNumber,
					Row_Status: 8,
					Children: {
						sales_order_detail: [{
							Sales_Order_Detail_SerialNumber: app.globalData.Open_ID+'_'+ time+'_001',
							Sales_Order_SerialNumber: app.globalData.Open_ID+'_'+ time,
							Sales_Unit_Price_Stock_SerialNumber: this.good.specifications[index].Sales_Unit_Price_Detail_SerialNumber,
							Sales_Unit_Price_Detail_SerialNumber: this.good.specifications[index].Sales_Unit_Price_Stock_SerialNumber,
							Article_SerialNumber: this.good.specifications[index].Article_SerialNumber,
							Article_Specifications_SerialNumber: this.good.specifications[index].Article_Specifications_SerialNumber,
							Sign: this.good.specifications[index].Sign,
							Quantity: this.good.quantity,
							Unit_Price: this.good.specifications[index].Unit_Price,
							Sales_Unit_Price: this.good.specifications[index].Sales_Unit_Price,
							Stock_Remain: this.good.specifications[index].Stock_Remain,
							Amount: accMul(this.good.quantity,this.good.specifications[index].Sales_Unit_Price),
							Row_Status: 8,
							Receive_Type: 0,
							Refund_Type: 0,
							Enterprise_Info_SerialNumber: app.globalData.Enterprise_Info_SerialNumber,
						}]
					},
				}
				var res = await this.getWXCheckShopCarAction(this.good.specifications[index].Article_SerialNumber);
				if (res.length == 0) {
					// 增加流程
					sales_order.Children.sales_order_detail[0].Amount = accMul(this.good.specifications[
							index]
						.Sales_Unit_Price, this.good.quantity)
					uni.showLoading({
						title: "加载中...",
					});
					var addres = await getAddAction({
						Data: JSON.stringify({
							sales_order: [sales_order]
						}),
						Open_ID: app.globalData.Open_ID
					})
					uni.hideLoading();
					if (addres.Status == "success") {
						uni.showToast({
							title: '提交成功！',
							icon: 'success'
						})
						const timer = setTimeout(() => {
							clearTimeout(timer)
							this.shopcart = false;
						}, 500)
					} else {
						uni.showToast({
							title: '提交失败！',
							icon: 'error'
						})
					}
				} else {
					uni.showLoading({
						title: "加载中...",
					});
					// 修改购物车商品数量   有问题 修改的不是当前规格的
					var editres = await editWXEditShopCarQuantity({
						Open_ID: app.globalData.Open_ID,
						Article_SerialNumber: res[0].Article_SerialNumber,
						Quantity: this.good.quantity,
						Type: "1"
					})
					uni.hideLoading();
					if (editres.Status == "success") {
						uni.showToast({
							title: '提交成功！',
							icon: 'success'
						})
						const timer = setTimeout(() => {
							clearTimeout(timer)
							this.shopcart = false;
						}, 500)
					} else {
						uni.showToast({
							title: '提交失败！',
							icon: 'error'
						})
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 购物车选中规格时样式
	.speActive {
		background-color: rgb(230, 248, 230);
		color: green
	}

	.shop-cart {
		width: 100%;

		.btn-left {
			padding: 0;
			margin: 0;
			width: 45%;
			border-radius: 0;
			border-top-left-radius: 50rpx;
			border-bottom-left-radius: 50rpx;
			background-color: #383838;
		}

		.btn-right {
			padding: 0;
			margin: 0;
			width: 45%;
			border-radius: 0;
			border-top-right-radius: 50rpx;
			border-bottom-right-radius: 50rpx;
			background-color: #09BB07;
		}
	}

	@media screen and (min-width:480px) {
		.goods_item {
			margin: 20rpx 69.9rpx !important;
		}
		
		.img_box {
			height: 650px;
		}

		.swiper_height {
			// width: 1200px;
			height: 650px;
		}
		.sheng_mokuai {
			width: 18%;
		}
	}

	@media screen and (max-width:480px) {
		.product-list {
			padding: 0 30rpx !important;
		}
		.scroll-Y{
			height:100vh;
		}
		.sheng_mokuai {
			width: 48%;
		}

		.img_box {
			height: 400rpx;
		}

		.sign_row {
			justify-content: space-between;
		}

		.goods_item {
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		.swiper_height {

			height: 400rpx;
		}
	}
</style>